package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.SocialEconomy;
import com.hbnu.system.service.SocialEconomyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/SocialEconomy")
@Api(tags = "纵向-项目的社会经济目标模块")
public class SocialEconomyController {
    @Autowired
    private SocialEconomyService socialEconomyService;

    @ApiOperation("项目的社会经济目标添加")
    @PostMapping("/addSocialEconomy")
    public Rest<Boolean> addSocialEconomy(@RequestBody SocialEconomy socialEconomy){
        boolean add = socialEconomyService.addSocialEconomy(socialEconomy);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取项目的社会经济目标列表")
    @GetMapping("/getSocialEconomy")
    public Rest<List<SocialEconomy>> getSocialEconomys(){
        List<SocialEconomy> projectcateList = socialEconomyService.getSocialEconomyList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("项目的社会经济目标-修改")
    @PostMapping("/updateSocialEconomy")
    public Rest<Boolean> updateSocialEconomy(@RequestBody SocialEconomy socialEconomyType){
        boolean update = socialEconomyService.updateSocialEconomy(socialEconomyType);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("项目的社会经济目标-删除")
    @GetMapping("/deleteSocialEconomy")
    public Rest<Boolean> deleteSocialEconomy(String socialEconomyID){
        boolean delete = socialEconomyService.deleteSocialEconomy(socialEconomyID);
        return delete ? Rest.success() : Rest.failed();
    }

}
